﻿function loadScript(url){
	document.writeln('<script type="text/javascript" src="' + common.getContextPath(url) + '"></script>');
}
function loadLink(url){
	document.writeln('<link type="text/css" rel="stylesheet" href="' + common.getContextPath(url) + '"></link>');
}
function loadMetaKeywords(keywords){
	document.writeln('<meta name="Keywords" content="' + keywords + '" />');
}
function loadTitle(title){
	document.writeln('<title>' + title + '</title>');
}

//jquery
loadScript('/common/jquery/jquery-1.5.1.min.js');
loadScript('/common/jquery/jquery.pagination.js');
loadLink('/common/jquery/pagination.css');
loadScript('/common/jquery/jquery.form.js');
loadScript('/common/jquery/validator/formValidator_min.js');
loadLink('/common/jquery/validator/style/validator.css');
loadScript('/common/js/jquery/validator/formValidatorRegex.js');

//date
//loadScript('/common/js/My97DatePicker/WdatePicker.js');
//image code
//loadScript('/common/jsp/imageCode/imageCode.js');
//common
loadScript('/common/jquery/common.html.js');
loadScript('/common/jquery/common.jquery.js');
loadScript('/common/jquery/common.validator.js');
//pv
//loadScript('/public/pv.js');
//other
loadScript('/public/public.js');
//loadScript('/public/login.js');
//loadLink('/css/public.css');

//loadScript('/user/shop/public/public.js');
//loadScript('/user/shop/public/DD_belatedPNG_0.0.8a.js');
//dialog
//loadScript('/common/js/dialog/dialog.js');
//loadLink('/common/js/dialog/styles/readbook_1.css');
//dtree
//loadScript('/common/js/dtree/dtree.js');
//loadLink('/common/js/dtree/styles/dtree.css');
//ckeditor
//loadScript('/common/js/ckeditor/ckeditor.js');
//loadScript('/public/ck/ck.js');


/*loadBmapLink('611969f763a6f3ece34ca4e3d6d734ff','1.1','true');*/
//引用百度地图API @author 王勇 @since 2010-11-24
/*function loadBmapLink(Bkey,ver,services){
	document.writeln('<style type="text/css">'+
	  ' html,body{margin:0;padding:0;}'+
	  '.iw_poi_title {color:#CC5522;font-size:14px;font-weight:bold;overflow:hidden;padding-right:13px;white-space:nowrap}'+
	  ' .iw_poi_content {font:12px arial,sans-serif;overflow:visible;padding-top:4px;white-space:-moz-pre-wrap;word-wrap:break-word}'+
	'</style>'+
	'<script type="text/javascript" src="http://api.map.baidu.com/api?key='+Bkey+'&v='+ver+'&services='+services+'"></script>'+
	'<script type="text/javascript" src="'+common.getContextPath('/public/emap.js')+'"></script>');
}
*/
function subString(str, len, hasDot) {
	var newLength = 0;
	var newStr = "";
	var chineseRegex = /[^\x00-\xff]/g;
	var singleChar = "";
	var strLength = str.replace(chineseRegex, "**").length;
	for (var i = 0; i < strLength; i++) {
	singleChar = str.charAt(i).toString();
	if (singleChar.match(chineseRegex) != null) {
	newLength += 2;
	}
	else {
	newLength++;
	}
	if (newLength > len) {
	break;
	}
	newStr += singleChar;
	}
	if (hasDot && strLength > len) {
	newStr += "…";
	}
	return newStr;
}
